Ben Bolker
2024-02-27
software engineers should worry about other issues (such as good algorithm design and good implementations of those algorithms) before they worry about micro-optimizations” (Hyde 2009)
Do you have other sh*t to do? No? Please contact me and I’ll help you with that. Yes? You are among the 90% of R users whose first priority is not computer programming. The time spent optimizing code is often longer than the computing time actually saved. Use the simple solutions and you can get on with your research/life. (Ross 2013)
system.time() for quick estimatesrbenchmark, microbenchmark packagesModified from Brooks et al. (2017):
Example random-walk code (Ihaka, Temple Lang, and McArdle 2009):
summaryRprof() (base-R), profvis package (RStudio fanciness)numeric() etc.)rbind() them togetherBurns (2012): “If you are using R and you think you’re in hell, this is a map for you.”
non-vectorized, growing objects
data.table > tidyverse > base Rarrow, vroom, direct database access (dbplyr)collapse, xts, Rfastslurm, batchtools, futures.batchtools packageparallel package, foreach/doParallelOpenMPoptim()optim() R will implement finite-difference gradients by defaultderiv() can only handle basic functionsDeriv packageTMB/RTMB (C++), Chau (2022) (Stan), autodiffr package (Julia)https://csgillespie.github.io/efficientR/performance.html
RcppArmadillo, RcppEigen